package chapter02;

public class BadSuspend {
	public static Object u = new Object();
	static changeObjectThread t1 = new changeObjectThread("t1");
	static changeObjectThread t2 = new changeObjectThread("t1");

	public static class changeObjectThread extends Thread {

		public changeObjectThread(String name) {
			super.setName(name);
		}

		@Override
		public void run() {
			synchronized (u) {
				System.out.println("in " + getName());
				Thread.currentThread().suspend();
			}

		}

	}

	public static void main(String[] args) throws InterruptedException {
		t1.start();
		Thread.sleep(100);
		t2.start();
		t1.resume();
		t2.resume();
		t1.join();
		t2.join();
	}

}
